<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<form id="soBillOrder" method="post" class="easyui-form">
    <table align="center" cellspacing="10">
        <tr>
            <td>
                <label for="customerId">客户:</label>
                <input class="easyui-combobox" id="customerId" name="customerId" style="width:170px;"
                       data-options="valueField:'id',textField:'name',method:'get',url:'api/people/customer/getCode',required:true"/>
            </td>
            <td>
                <input class="easyui-datebox" id="dealDate" name="dealDate" style="width:100%" data-options="label:'交货日期:',required:true"/>
            </td>

        </tr>
        <tr>
            <td>
                <label for="receivingType">收款方式:</label>
                <select class="easyui-combobox" id="receivingType" name="receivingType"  style="width:140px;" >
                    <option value="1">现金收款</option>
                    <option value="0">记应收账款</option>
                </select>
            </td>
            <td>
                <input class="easyui-combobox" name="orgId" style="width:100%"
                       data-options="label:'组织机构:',valueField:'id',textField:'fullName',method:'get',url:'api/people/org/list'"/>
            </td>
        </tr>
        <tr>
            <td>
                <label for="bizUserId">业务员：</label>
                <input class="easyui-combobox" id="bizUserId" name="bizUserId"  data-options="valueField:'id',textField:'name',method:'get',url:'api/people/user',required:true"/>
            </td>
            <td>
                <input class="easyui-combobox" id="inputUserId" name="inputUserId"  style="width:100%" data-options="label:'制单人',valueField:'id',textField:'name',method:'get',url:'api/people/user',required:true"/>
            </td>

        </tr>
        <tr>
            <td colspan="3">
                <input class="easyui-textbox" name="dealAddress" id="dealAddress" style="width:100%;height:30px"  data-options="label:'交货地址:',required:true"/>
            </td>
        </tr>
        <tr>
            <td colspan="3">
                <input class="easyui-textbox" name="billMemo" style="width:100%;height:30px"
                       data-options="label:'备注:'">

            </td>
        </tr>
        <tr>
            <td colspan="3" align="center">
                <a data-options="iconCls:'icon-ok'" class="easyui-linkbutton" onclick="saveOrder()">保存</a>
                <a data-options="iconCls:'icon-no'" class="easyui-linkbutton" onclick="clearOrder()"
                   style="margin-left: 60px;">重置</a>
            </td>
        </tr>
    </table>
</form>
<script>
    $(function () {

    	$('#dealDate').datebox({
    		onSelect: function(date){
    			var dataTemp=new Date();
    			if(date<dataTemp){
    				$('#dealDate').datebox('setValue', dataTemp.getFullYear()+"-"+(dataTemp.getMonth()+1)+"-"+dataTemp.getDate());
    			}
    		}
    	});
    })
    function saveOrder() {
        $('#soBillOrder').form('submit', {
            url: 'api/bill/so',
            onSubmit: function () {
                return $(this).form('enableValidation').form('validate');
            }, success: function (data) {
                data = eval('(' + data + ')');
                if (data.data != null) {
                    $.messager.show({
                        title: '温馨提示',
                        msg: data.message,
                        timeout: 3000,
                        showType:'show',
                    	style:{
                    		right:'',
                    		bottom:''
                    	}
                    });
                    
                    $('#addSoBillDialog').dialog('close');
                    $('#soBillGrid').datagrid('reload');
                } else {
                    $.messager.alert('失败提示', data.message, 'warning');
                    $('#soBillOrder').form('clear');
                }
            }
        });
    }
</script>
